parser grammar JSXParser;

options {
  tokenVocab = JSXLexer;
}

jsx: block+;

// block
block: js | blockJsx | htmlElement  ;

blockJsx: LP jsx RP;
js: JS;

// html
htmlElement:htmlWithChildren | htmlNoChildren;    

htmlWithChildren: htmlStart 
    htmlAttributes TAG_CLOSE 
    htmlContent HTML_CLOSE;
htmlNoChildren : htmlStart
    htmlAttributes 
    TAG_SLASH_CLOSE ;

htmlStart: HTML_TAG_OPEN | TAG_OPEN;
// attr
htmlAttributes: htmlAttribute*;
htmlAttribute 
    : TAG_NAME TAG_EQUALS htmlAttrValue 
    | TAG_NAME
    ;
htmlAttrValue : TAG_VALUE | blockJsx;

// content
htmlContent: htmlChardata? (htmlContentJsx | htmlElement)* htmlChardata?;
htmlChardata: HTML_WS | HTML_TEXT;
htmlContentJsx: HTML_LP jsx RP;




